#include <iostream>
#include <vector>
#include <string>

using namespace std;

class Solution {
public:
	void rotate(int nums[], int n, int k) {
		if(n<=1)
			return;
		foo3(nums,n,k%n);
	}
private:
	void foo1(int nums[], int n, int k) {
		int c=k;
		while(c>0){
			int key=nums[n-1];
			for(int i=n-1;i>0;--i){
				nums[i]=nums[i-1];
			}
			nums[0]=key;
			--c;
		}
	}
	void foo2(int nums[], int n, int k) {
		vector<int> buf;
		int p=n-1;
		int c=k;
		while(c>0){
			buf.push_back(nums[p]);
			--p;
			--c;
		}
		for(int i=n-k-1;i>=0;--i){
			nums[i+k]=nums[i];
		}
		for(int i=0;i<k;++i){
			nums[i]=buf[k-i-1];
		}
	}
	void foo3(int nums[], int n, int k) {
		vector<int> buf;
		int c=n;
		int p=(n-k)%n;
		while(c>0){
			buf.push_back(nums[p]);
			--c;
			p=(p+1)%n;
		}
		for(int i=0;i<n;++i){
			nums[i]=buf[i];
		}
	}
};

void display(int* nums,int n){
	cout<<"[";
	for(int i=0;i<n;++i){
		cout<<nums[i]<<",";
	}
	cout<<"]"<<endl;
}

int main(){
	Solution s;
	int k;
	int nums[]={1,2,3,4,5,6,7};
	int n=sizeof(nums)/sizeof(int);
	display(nums,n);
	while(true){
		cin>>k;
		s.rotate(nums,n,k);
		display(nums,n);
	}
}